package com.yuntsg.nnsfcp.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class ParseJson {

    public static void main(String[] args) {

//        String ss = "{\"A\":\"XING, YP\",\"C\":2,\"D\":\"10.1093/JPE/RTX061\",\"T\":\"EFFECTS OF SALINITY AND CLONAL INTEGRATION ON THE AMPHIBIOUS PLANT PASPALUM PASPALOIDES: GROWTH, PHOTOSYNTHESIS AND TISSUE ION REGULATION\",\"U\":\"000461146700005\"}";
//        JSONObject jsonObject = JSON.parseObject(ss);
//        if (jsonObject.get("U")!=null){
//            System.out.println(jsonObject.getString("U"));
//        }

        String s2 = "{48876619:[\"hao, yanjie\"],60757388:[\"hao, yanjie\"],34177598:[\"hao, yanjie\"],49377369:[\"hao, yanjie\"],58521889:[\"hao, yanjie\"]}";

        JSONObject jsonObject1 = JSON.parseObject(s2);
        Set strings = jsonObject1.keySet();
        List<String> keys = new ArrayList<>();
        for (Object string : strings) {
            keys.add(string.toString());
        }
        for (String string : keys) {
            System.out.println("+++++++++开始+++++++++");
            System.out.println(string);
            JSONArray o = (JSONArray) jsonObject1.get(Integer.valueOf(string));
            List<String> list = o.toJavaList(String.class);
            for (String s : list) {
                //这块如果想解析换成,分割的
                System.out.println("+++++++++++输出分割的++++++++++++");
                String[] split = s.split(",");
                for (String s1 : split) {
                    System.out.println(s1);
                }
                System.out.println("!!!!!!!下面输出全部的!!!!!!!!!!!!");
                System.out.println(s);
            }
            System.out.println("-----------结束------------");
        }
    }
}
